package org.jerrymouse.jsa4j.db.kv.example.dao;

import org.jerrymouse.jsa4j.db.kv.DB;
import org.jerrymouse.jsa4j.db.kv.DBManagerFactory;
import org.jerrymouse.jsa4j.db.kv.Indexer;
import org.jerrymouse.jsa4j.db.kv.Repository;

public class RepositoryFactory {
	private static DB db;

	public static Repository getRepository(String prefix) {
		Repository repository = new Repository(prefix, getDB());
		return repository;
	}

	public static Indexer getIndexer(String prefix) {
		Indexer indexer = new Indexer(prefix, getDB());
		return indexer;
	}

	private static DB getDB() {
		if (db == null)
			db = new DBManagerFactory().getDBManager("derby-db").getDB();
		return db;
	}
}
